package com.ys.controller.web.sys;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bo.vo.W;
import com.ys.entity.sys.YsRole;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.YsRoleService;

@Controller
@RequestMapping("/web/sys/ysRole")
public class WebYsRoleController {
	
	private static Long MENU_ID = 37L;
	
	@Autowired
	private CommonApiService<YsRole> commonService;
	
	@Autowired
	private YsRoleService ysRoleService;
	
	/*
	 * 新增
	 */
	@GetMapping("/toAdd")
	public String toAdd(Model model, HttpServletRequest request, HttpServletResponse response){

		try {
			return commonService.toAdd(model, new YsRole(), MENU_ID, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, e.getMessage());
		}
	}
	
	/*
	 * 新增
	 */
	@GetMapping("/toEdit")
	public String toEdit(Model model, HttpServletRequest request, HttpServletResponse response,
			Long id){

		try {
			return commonService.toEdit(model, id, new YsRole(), MENU_ID, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, e.getMessage());
		}
	}
	
	/*
	 * 授权页
	 */
	@GetMapping("/toAuth")
	public String toAuth(Model model, HttpServletRequest request, HttpServletResponse response,
			Long roleId){
		
		return ysRoleService.toAuth(model, roleId);
	}
}
